package com.kgc.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.kgc.pojo.Person;
import com.kgc.pojo.User;

@Controller
public class LoginController
{
    /**
     * 
     * <跳转到login.jsp> <功能详细描述>
     * 
     * @return
     * @see [类、类#方法、类#成员]
     */
    @RequestMapping("login.html")
    public String login()
    {
        return "login";
    }
    
    @RequestMapping("test.do")
    public String test(@ModelAttribute User user)
    {
        return "../../index";
    }
    
    @RequestMapping("dateTest.do")
    public void test2(Person p)
    {
        System.out.println(p);
    }
    
    @InitBinder
    public void initBinder(WebDataBinder dataBinder)
    {
        System.out.println("initBinder=======================");
        
        dataBinder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
    }
    
}
